package com.dgz.system.controller.question;

import com.dgz.common.core.controller.BaseController;
import com.dgz.common.core.domain.R;
import com.dgz.common.core.domain.TableDataInfo;
import com.dgz.system.domain.question.Question;
import com.dgz.system.domain.question.dto.QuestionAddDto;
import com.dgz.system.domain.question.dto.QuestionEditDto;
import com.dgz.system.domain.question.dto.QuestionQueryDto;
import com.dgz.system.domain.question.vo.QuestionDetailVO;
import com.dgz.system.service.question.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2025/04/03/13:48
 * @Description:
 */
@RestController
@RequestMapping("/question")
@Tag(name = "题目管理接口")
public class QuestionController extends BaseController {

    @Autowired
    private IQuestionService iQuestionService;

    @GetMapping("/list")
    public TableDataInfo get(QuestionQueryDto questionQueryDto) {
        return getTableDataInfo(iQuestionService.list(questionQueryDto));
    }

    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDto questionAddDto) {
        return toR(iQuestionService.add(questionAddDto));
    }


    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId) {
        return R.ok(iQuestionService.detail(questionId));
    }

    @PutMapping("edit")
    public R<Void> edit(@RequestBody QuestionEditDto questionEditDto) {
        return toR(iQuestionService.edit(questionEditDto));
    }

    @DeleteMapping("/delete")
    public R<Void> delete(Long questionId) {
        return toR(iQuestionService.delete(questionId));
    }
}
